@echo off
@rem This is where the project-specific tests will go

setlocal

set exe=python_d
set previous=%CD%
set ERROR=0
set stable=
set tool=%~pd0
set version=
PATH %CD%\PCbuild;%PATH%

:CheckOpts
if "%1"=="stable" (set stable=y) & (set version=0.6c5) & shift & goto CheckOpts
if "%1"=="dev" (set version=dev) & shift & goto CheckOpts
if defined version goto Remove

:Error
@echo ERROR: First argument must be one of (stable, dev)
@set ERROR=1
@goto End

:Remove
@echo Removing Build Directory
@set build=%tool%\setuptools-%version%
@%exe% %tool%\rmtree.py %build%

:Fetch
@rem Use system python to fetch (assume it's 'python.exe').
@cd %tool%
@python ez_setup.py -e -b %build% setuptools==%version% 
@if %ERRORLEVEL% NEQ 0 (set ERROR=%ERRORLEVEL%)

:Test
@cd %build%\setuptools
%exe% setup.py test -vv
@if %ERRORLEVEL% NEQ 0 (set ERROR=%ERRORLEVEL%)

:Install
%exe% setup.py install
@if %ERRORLEVEL% NEQ 0 (set ERROR=%ERRORLEVEL%)

@echo off
cd %previous%

:End
exit /b %ERROR%
